-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(Table): skip validate on Excel model #6017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR introduces an optional skipValidate flag in the component creation utility to dynamically disable validation, applies it in Table rendering paths, updates the related unit test, and bumps the project version. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new optional skipValidate parameter to the CreateComponentByFieldType method, enabling components to bypass validation when needed. Key changes include updating the method signature and logic in Utility.cs, modifying the corresponding unit test to include the parameter, and adjusting the Table.razor.cs component rendering to utilize the new functionality.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/UnitTest/Utils/UtilityTest.cs | Updated test to pass skipValidate: true to validate the new behavior |
| src/BootstrapBlazor/Utils/Utility.cs | Added the skipValidate parameter to CreateComponentByFieldType and adjusted attribute-setting logic accordingly |
| src/BootstrapBlazor/Components/Table/Table.razor.cs | Updated component rendering calls to include skipValidate: true |
| src/BootstrapBlazor/BootstrapBlazor.csproj | Updated the project version from 9.6.2-beta03 to 9.6.2-beta04 |
| builder.AddAttribute(150, nameof(Select<SelectedItem>.ShowSearch), item.ShowSearchWhenSelect); | ||
| } | ||
|
|
||
| // 设置 SkipValidate 参数 |
Copilot
AI
May 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding an inline comment clarifying the decision to skip adding the SkipValidate attribute when skipValidate is true, to assist future maintainers.
| // 设置 SkipValidate 参数 | |
| // 设置 SkipValidate 参数 | |
| // Add the SkipValidate attribute only if skipValidate is false and the component type is valid. | |
| // This ensures that validation is skipped only when explicitly allowed by the conditions. |
| { | ||
| builder.AddAttribute(70, nameof(ValidateBase<string>.ShowLabelTooltip), item.ShowLabelTooltip); | ||
| } | ||
|
|
Copilot
AI
May 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document that a null value for skipValidate is treated as false to ensure API consumers understand the default behavior.
| // If skipValidate is null, it is treated as false by default. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6017 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 670 670
Lines 30653 30657 +4
Branches 4362 4363 +1
=========================================
+ Hits 30653 30657 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- Update the CreateComponentByFieldType_Ok unit test to assert that the SkipValidate attribute is actually rendered when skipValidate=true.
- Consider changing skipValidate from a nullable bool to a non-nullable bool with default false to simplify the conditional logic.
- Please double-check the sequence numbers of the new AddAttribute calls to ensure they don’t collide and maintain the correct render order.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" })); | ||
| var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" }, skipValidate: true)); | ||
| var cut = Context.Render(builder => builder.AddContent(0, fragment)); | ||
| Assert.Contains("value=\"Test-Component\"", cut.Markup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Enhance assertion to verify SkipValidate attribute presence.
Update the assertion to verify the rendered markup includes the SkipValidate attribute or that the component instance’s skipValidate parameter is true.
| Assert.Contains("value=\"Test-Component\"", cut.Markup); | |
| Assert.Contains("value=\"Test-Component\"", cut.Markup); | |
| // Verify that SkipValidate attribute is rendered | |
| Assert.Contains("skip-validate", cut.Markup); |
Link issues
fixes #6016
Summary By Copilot
This pull request introduces a new
skipValidateparameter to theCreateComponentByFieldTypemethod and applies it across various components to enhance flexibility in validation logic. Additionally, it updates the project version and adjusts related unit tests.Feature Enhancements:
CreateComponentByFieldTypeMethod Update:skipValidateparameter to control validation behavior dynamically.SkipValidateattribute to components whenskipValidateis set totrue.skipValidateis enabled.Code Integration:
RenderEditTemplateandSetDynamicEditTemplatemethods inTable.razor.csto utilize the newskipValidateparameter. [1] [2]Testing and Validation:
CreateComponentByFieldType_Oktest to include theskipValidateparameter, ensuring the new functionality is tested.Versioning:
BootstrapBlazor.csprojfrom9.6.2-beta03to9.6.2-beta04.Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Introduce an optional skipValidate parameter to allow conditional skipping of validation in dynamically generated components, apply this behavior to table edit templates, update tests accordingly, and increment the project version to 9.6.2-beta04.
New Features:
Build:
Tests: